package demo;

import java.util.Scanner;

/**
 * @Author liangzai
 * @Description:
 */
public class Training {
    //数字三角形
    public static void main1(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[][] nums = new int[n+1][n+1];
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= i; j++) {
                nums[i][j] = scanner.nextInt();
            }
        }
        int[][] dp = new int[n+1][n+1];
        //dp[1][1] = nums[1][1];
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= i; j++) {
                dp[i][j] = Math.max(dp[i-1][j], dp[i-1][j-1])+nums[i][j];
            }
        }
        if(n%2==1) {
            System.out.println(dp[n][n/2+1]);
        }else {
            System.out.println(Math.max(dp[n][n/2], dp[n][n/2+1]));
        }
        //System.out.println(max);
    }

    //数列求值
    public static void main2(String[] args) {
        int a = 1;
        int b = 1;
        int c = 1;
        int sum = 0;
        int count = 3;
        while(count!=20190324) {
            sum = (a+b+c)%10000;
            System.out.println(sum);
            int tmp = a;
            int tmp2 = b;
            a = sum;
            b = tmp;
            c = tmp2;
            count++;
        }
    }

    //温度单位的转换
    public static void main3(String[] args) {
        //System.out.println((int)-5.4);
        Scanner scanner = new Scanner(System.in);
        int c = scanner.nextInt();
        int f = (int)(c*1.8f + 32) ;
        System.out.println(f);
    }

    //反转字符串中的字符
    public static void main4(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        StringBuffer stringBuffer = new StringBuffer();
        int len = str.length();
        int pcur = len-1;
        while(pcur>=0) {
            stringBuffer.append(str.charAt(pcur--));
        }
        String ret = stringBuffer.toString();
        System.out.println(ret);
    }

    //成绩统计
    public static void main5(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int count1 = 0;
        int count2 = 0;
        int val = 0;
        for (int i = 0; i < n; i++){
            val = scanner.nextInt();
            if(val>=60) {
                count1++;
            }
            if(val>=85) {
                count2++;
            }
        }
        int key1 = fun((int)(count1*1000/n));
        int key2 = fun((int)(count2*1000/n));
        System.out.println(key1+"%");
        System.out.println(key2+"%");
    }

    private static int fun(int n) {
        if(n%10>=5) {
            return n/10+1;
        }else {
            return n/10;
        }
    }

    //数组分割
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            int num = scanner.nextInt();
            nums[i] = fun1(num);
        }
        for (int i = 0; i < n; i++) {
            System.out.println(nums[i]);
        }
    }

    private static int fun1(int n) {
        Scanner scanner = new Scanner(System.in);
        int sum = 0;
        long count = 1;
        int[] nums = new int[n+1];
        for (int i = 1; i <= n; i++) {
            nums[i] = scanner.nextInt()%2;
            sum += nums[i];
            if(nums[i]==0) {
                count++;
            }
        }
        if(sum%2==1) {
            return 0;
        }
        for (int i = 1; i <= n; i++) {
            int val = nums[i];
            for (int j = i+1; j <= n; j++) {
                val += nums[j];
                if(val%2==0) {
                    count++;
                }else {
                    break;
                }
            }
        }
        return (int)(count%1000000007l);
    }
}
